package com.epalmpay.commom;

import com.epalmpay.dto.mall.CitiesOutDTO;
import com.epalmpay.dto.mall.CityOutDTO;
import com.epalmpay.service.common.ICitiesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created by lifayi on 2017/8/4.
 */
@RestController
@RequestMapping("/manager/cities")
public class CitiesController {

    @Autowired
    private ICitiesService citiesService;

    @RequestMapping("/listProvinces")
    public CitiesOutDTO listProvinces(@RequestBody Integer[] requestCityInfo) {
        if(requestCityInfo[0] == null || requestCityInfo[1] == null) {
            return null;
        } else {
            return citiesService.listProvinces(requestCityInfo);
        }
    }

    @RequestMapping("/listByParentId")
    public CitiesOutDTO listByParentId(@RequestBody Map<String, Integer> citiesInfo) {
        return citiesService.listByParentId(citiesInfo);
    }
}
